/**
 * @(#)ApkConfigController.java 2016年12月1日
 * Copyright(C) 2016 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.action;

import java.util.List;

import javax.annotation.Resource;

import org.jsbd.boss.dao.IDmChannelRetentDAO;
import org.jsbd.boss.domian.channel.TaskRecord;
import org.jsbd.boss.domian.channel.TaskRecordVo;
import org.jsbd.boss.service.ITaskRecordService;
import org.jsbd.boss.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;

/**
 * apk配置
 * 
 * @author <a href="mailto:xupengcheng@zhexinit.com" >徐鹏程</a>
 * @version 1.0.0
 */
@Controller
@RequestMapping("/task")
public class TaskQueryController {
	public static final Logger LOGGER = LoggerFactory.getLogger(TaskQueryController.class);

	@Resource
	private ITaskRecordService taskRecordService;

	@Resource
	private IDmChannelRetentDAO dmChannelRetentDAO;

	@RequestMapping(value = "taskList", method = RequestMethod.GET)
	public String list(Model model) {
		TaskRecordVo vo = new TaskRecordVo();
		vo.setCurrDay(DateUtil.getCurrentDateStr());
		List<TaskRecord> list = taskRecordService.selectRecords(vo);
		if (list != null && list.size() > 0) {
			model.addAttribute("taskList", JSONObject.toJSONString(list));
		} else {
			model.addAttribute("taskList", "[]");
		}
		return "/newtask/taskList";
	}

	@RequestMapping(value = "taskList", method = RequestMethod.POST)
	@ResponseBody
	public String list(Model model, TaskRecordVo record) {
		List<TaskRecord> list = taskRecordService.selectRecords(record);
		if (list != null && list.size() > 0) {
			return JSONObject.toJSONString(list);
		} else {
			return "[]";
		}
	}

	@RequestMapping(value = "remove")
	@ResponseBody
	public void remove(TaskRecordVo record) {
		taskRecordService.remove(record);
	}

}
